# coding=utf-8
"""

"""
import os
from flask import Blueprint, render_template
from utils.do_yml import do_yml
from utils.do_path import CARD_PIC_FOLDER

# @Time    : 2024/12/12 15:44
# @Author  : ginger
# @Email   : gingerqgyy@outlook.com
# @Project : curl_conversion
# @File    : view_idcard.py

card = Blueprint('card', __name__, template_folder='templates')


@card.route('show_idcard', methods=['GET', 'POST', ])
def show_idcard():
    id_card_s = do_yml.get()
    for person in id_card_s:
        person['idcard'] = str(person['idcard'])
    return render_template('show_idcard.html', data=id_card_s)


@card.route('show_idcard_pic', methods=['GET', 'POST', ])
def show_idcard_pic():
    # image_files = [os.sep.join([CARD_PIC_FOLDER, f]) for f in os.listdir(CARD_PIC_FOLDER) if f.endswith(('.jpg', '.jpeg', '.png'))]
    image_files = [f for f in os.listdir(CARD_PIC_FOLDER) if f.endswith(('.jpg', '.jpeg', '.png'))]
    image_files = image_files[:21]
    return render_template('show_idcard_pic.html', images=image_files)
